package com.qf.controller;

import com.qf.pojo.Patient;
import com.qf.service.PatientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/patient")
public class PatientController {
    @Autowired
    private PatientService patientService;
    @RequestMapping("/selectByNameAndIdentityId")
    @ResponseBody
   public List<Patient> selectByNameAndIdentityId(@RequestParam("name")String name,@RequestParam("identityId")String identityId){
        Patient patient=new Patient();
        patient.setName(name);
        patient.setIdentityId(identityId);
        List<Patient> select = patientService.select(patient);
        return select;
    }
    @RequestMapping("/insert")
    @ResponseBody
    public String insert(Patient patient){
        int insert = patientService.insert(patient);
        if(insert==1){
            return "success";
        }
        return "error";
    }

}
